﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SowUpdate.aspx.cs" Inherits="OnlineManagement.Web.pages.SowUpdate" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="../resources/scripts/jquery-1.10.2.js" type="text/javascript"></script>
    <script src="../resources/scripts/myAjax.js" type="text/javascript"></script>
    <script src="../resources/scripts/sow.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#<%=ddlPigPen.ClientID %>").attr("style", "display:none");
            $("#changeNum").click(function () {
                var pigPen = $("#<%=ddlPigPen.ClientID %>");
                var style = pigPen.attr("style");
//                var explorer = window.navigator.userAgent.toLowerCase();
//                //ie
//                if (explorer.indexOf("msie") >= 0) {
                //                }
                //style : "display:none"
                if (pigPen.attr("style").indexOf("none") >= 0) 
                {
                    pigPen.attr("style", "display:block");
                }
                else {
                    pigPen.attr("style", "display:none");
                }


//                if (pigPen.attr("style") == "display:none") {
//                    pigPen.attr("style", "display:block");
//                } else {
//                    pigPen.attr("style", "display:none");
//                }
            });
            $("#<%=ddlPigPen.ClientID %>").change(function () {
                var selected = $(this).find("option:selected").text();
                $("#<%=lbPigPenId %>").val(selected);
            });

        });

        function save() {
           var sowId = $("#<%=hfSowId.ClientID %>").val();
           var changedPigPenId = $("#<%=ddlPigPen.ClientID %>").val();
           var hybridizationCount = $("#<%=txthybridizationCount.ClientID %>").val();
           var propagateCount = $("#<%=txtPropagateCount.ClientID %>").val();
           var propagateStateID = $("#<%=ddlPropagateState.ClientID %>").val();
           var comment = $("#<%=txtComment.ClientID %>").text();
           $.ajax2({
               type: "post",
               contentType: "application/json",
               url: "../WebServices/Sows.asmx/UpdateSow",
               dataType: "json",
               data: "{ sowId: '" + sowId + "',changedPigPenId:'" + changedPigPenId + "',hybridizationCount:'" + hybridizationCount + "',propagateCount:'" + propagateCount
                    + "',propagateStateID:'" + propagateStateID + "',comment:'" + comment + "' }",
               success: function (data) {
                   if (data.d.Flag) {
                       $("#msg > div").remove();
                       var span = "<div class='notification success png_bg'> <a href='#' class='close'><img src='../resources/images/icons/cross_grey_small.png' title='关闭' alt='关闭' /></a><div>" + data.d.Message + "</div></div>";
                       $("#msg").append(span);
                   } else {
                       $("#msg > div").remove();
                       var span = "<div class='notification attention png_bg'> <a href='#' class='close'><img src='../resources/images/icons/cross_grey_small.png' title='关闭' alt='关闭' /></a><div>" + data.d.Message + "</div></div>";
                       $("#msg").append(span);
                   }
               },
               error: function (error) {
                   $("#msg > div").remove();
                   var span = "<div class='notification error png_bg'> <a href='#' class='close'><img src='../resources/images/icons/cross_grey_small.png' title='关闭' alt='关闭' /></a><div>提交失败：" + error.status + "</div></div>";
                   $("#msg").append(span);
               }

           });
       }

    </script>
</head>
<body>
    <form id="form1" runat="server">
   <div class="tab-content" id="tab2">
            <fieldset>
             <p>
              <label>母猪耳号:</label>
                 <asp:Label ID="lbBitID" runat="server" Text="Label"></asp:Label>
      <!--        <input class="text-input small-input" type="text" id="small-input" name="small-input" />-->
             <%-- <span class="input-notification success png_bg">Successful message</span>--%>
              <!-- Classes for input-notification: success, error, information, attention -->
              <br />
            </p>
          
            <p>
                <label>猪圈编号:&nbsp;
                    <asp:Label runat="server" ID="lbPigPenId"></asp:Label>&nbsp;
                    <a id="changeNum" href="javascript:void(0);">改变编号?</a>
                 <%--   <asp:LinkButton ID="lbtnChangeNum" runat="server">改变编号</asp:LinkButton>--%>
                </label>
                <asp:DropDownList runat="server" ID="ddlPigPen" AutoPostBack="false"></asp:DropDownList>
            </p>
            <p>
              <label>配种次数</label>
                <asp:TextBox ID="txthybridizationCount" runat="server" CssClass="text-input small-input" onkeyup="JavaScript:this.value=this.value.replace(/\D/gi,'')"></asp:TextBox>
             <small>请输入数字,不填即为0</small>
             </p>
            <p>
              <label>已生产胎数</label>
                <asp:TextBox ID="txtPropagateCount" runat="server" CssClass="text-input small-input" onkeyup="JavaScript:this.value=this.value.replace(/\D/gi,'')"></asp:TextBox>
              <small>请输入数字，不填即为0</small>
             </p>
            <p>
              <label>繁育状态</label>
              <asp:DropDownList ID="ddlPropagateState" runat="server" CssClass="small-input" AutoPostBack="false"></asp:DropDownList>
            </p>
            <p>
              <label>备注说明</label>
                <asp:TextBox ID="txtComment" runat="server" TextMode="MultiLine" ></asp:TextBox>
            </p>
            <p>
              <input id="btnSave" value="保存" type="button" onclick="save();"  />
             </p>
             <p>
                <div id="msg"></div>
             </p>
             <asp:HiddenField runat="server" ID="hfSowId" />
            </fieldset>
            <div class="clear"></div>
            <!-- End .clear -->
        </div>
           
    </form>
</body>
</html>
